package org.eclipse.moquette.parser.netty;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import org.eclipse.moquette.proto.messages.AbstractMessage;
import org.eclipse.moquette.proto.messages.UnsubAckMessage;

/**
 * Created by alex on 15-5-26.
 */
public class UnsubAckEncoder extends DemuxEncoder<UnsubAckMessage> {

    @Override
    protected void encode(ChannelHandlerContext ctx, UnsubAckMessage msg, ByteBuf out) {
        out.writeByte(AbstractMessage.UNSUBACK << 4)
                .writeBytes(Utils.encodeRemainingLength(2))
                .writeShort(msg.getMessageID());
    }
}
